using System;
using System.Collections.Generic;

namespace Admin.NET.Application;

public class MeterOutPut : ElectricMeter
{
	public string UserName { get; set; }

	public long? UserId { get; set; }

	public string UserPhone { get; set; }

	public ElectricityPriceRule PriceInfo { get; set; }

	public Room RoomInfo { get; set; }

	public string RoomName { get; set; }

	/// <summary>
	/// 区域/楼栋名称
	/// </summary>
	public string BuildingName { get; set; }

	public string PriceName { get; set; }

	public string LabelName { get; set; }

	public new long Pid { get; set; }

	/// <summary>
	/// 区域子项
	/// </summary>
	public List<MeterOutPut> Children { get; set; } = new List<MeterOutPut>();


	public bool IsCurrentElectricityProtection
	{
		get
		{
			if (!base.IsElectricityProtection)
			{
				return false;
			}
			if (!base.ElectricityProtectionBegin.HasValue && !base.ElectricityProtectionEnd.HasValue)
			{
				return true;
			}
			DateTime now;
			DateTime value;
			DateTime? electricityProtectionEnd;
			if (!base.ElectricityProtectionBegin.HasValue)
			{
				now = DateTime.Now;
				value = now;
				electricityProtectionEnd = base.ElectricityProtectionEnd;
				if (value > electricityProtectionEnd)
				{
					return false;
				}
				return true;
			}
			if (!base.ElectricityProtectionEnd.HasValue)
			{
				now = DateTime.Now;
				value = now;
				electricityProtectionEnd = base.ElectricityProtectionBegin;
				if (value < electricityProtectionEnd)
				{
					return false;
				}
				return true;
			}
			now = DateTime.Now;
			value = now;
			electricityProtectionEnd = base.ElectricityProtectionBegin;
			if (value > electricityProtectionEnd)
			{
				value = now;
				electricityProtectionEnd = base.ElectricityProtectionEnd;
				if (value < electricityProtectionEnd)
				{
					return true;
				}
			}
			return false;
		}
	}
}
